package com.atguigu.e_reflect.method;

import java.lang.reflect.Method;

public class Demo {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        //反射第一步 : 获取类的字节码对象
        Class<?> clazz = Class.forName("com.atguigu.e_reflect.method.Student");

        //拿所有的成员方法对象
        Method[] methods = clazz.getDeclaredMethods();
        for (Method method : methods) {
            System.out.println("method = " + method);
        }

        System.out.println("----------------------------");
        //获取sleep方法对象
        Method sleep = clazz.getDeclaredMethod("sleep");
        System.out.println("sleep = " + sleep);

        Method eat = clazz.getDeclaredMethod("eat", String.class);
        System.out.println("eat = " + eat);

        Method study = clazz.getDeclaredMethod("study");
        System.out.println("study = " + study);

        Method playGame = clazz.getDeclaredMethod("playGame", String.class, int.class);
        System.out.println("playGame = " + playGame);


    }
}
